<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title></title>

		<style type="text/css">
			.img {
				height: 200px;
			}
		</style>


	</head>
	<body>

		<img id="img" src='' class="img"  />

		<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js">
		</script>
		<script src="https://cdn.bootcdn.net/ajax/libs/tracking.js/1.1.3/data/eye-min.js"></script>
		<script src="https://apitiyu.bigchun.com/js/face-api.min.js"></script>
		<script type="text/javascript" charset="utf-8">
			var isReady = false

			// 待触发 `UniAppJSBridgeReady` 事件后，即可调用 uni 的 API。
			document.addEventListener('UniAppJSBridgeReady', () => {
				isReady = true;
			});

			function setFaceImg(imgPath) {
				var img = document.getElementById("img");
				img.src = imgPath;
				var tracker = new tracking.ObjectTracker(['face']);
				tracker.setStepSize(1.7)
				tracking.track('#img', tracker);
				tracker.on('track', function(event) {
					if (isReady) {
						uni.postMessage({
							data: {
								code: event.data.length,
								imgPath: imgPath
							}
						});
					}
				});
			}

		</script>
	</body>
</html>

